﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Data.SqlClient;
using DevExpress.XtraEditors.Controls;

namespace TCCT_CTC_CSDLDangVienV1
{
    public partial class frmCanBo_QTDT : frmBase
    {
        public string SelectedDauMoiID = "";
        public string FilterString = "";
        public string ConditionString = "";
        public string SelectedKhoa = "";

        public frmCanBo_QTDT()
        {
            InitializeComponent();
        }

        private void frmCanBo_QTDT_Load(object sender, EventArgs e)
        {

            if (SelectedDauMoiID == "")
                SelectedDauMoiID = MyCommon.CurrentUserDauMoiID;
            ApplyUI();

            BindDataToColtrol();


        }

        private void ApplyUI()
        {



            UI.Button.ApplyAccept(btnAccept);
            UI.Button.ApplyCancel(btnCancel);


        }
        private void BindDataToColtrol()
        {


            string sQT = "";
            DataTable temQT = new DataTable();

            temQT = SqlHelper.ExecuteDataTable(CommandType.Text, "Select HoTen_KS, So_Hieu_SQ From tblCanBo Where Khoa='" + SelectedKhoa + "' And DauMoiID='" + SelectedDauMoiID + "' ");

            txtTen.Text = temQT.Rows[0]["HoTen_KS"].ToString();
            txtSH.Text = "SHSQ: " + MyCommon.SHSQ_Parse(temQT.Rows[0]["So_Hieu_SQ"].ToString());

            sQT = "* QT ĐT:\r\n";
            temQT = SqlHelper.ExecuteDataTable(CommandType.Text, "Select *, dbo.GetTuDien('TDTruong', QT.Ten_Co_So, QT.DauMoiID) As TenTruong, dbo.GetTuDien('TDNg_CNDT', QT.CNganh_DT, QT.DauMoiID) As NganhDaoTao  From tblQT_DT QT Where Khoa='" + SelectedKhoa + "' And DauMoiID='" + SelectedDauMoiID + "'  And Deleted=0");

            for (int i = 0; i < temQT.Rows.Count; i++)
            {
                sQT += " - " + temQT.Rows[i]["TenTruong"].ToString() + " - " + temQT.Rows[i]["NganhDaoTao"].ToString() + " - (" + MyCommon.GetMMyyyy(temQT.Rows[i]["Thang_BD"]) + " - " + MyCommon.GetMMyyyy(temQT.Rows[i]["Thang_KT"]) + ")\r\n";
            }

            
            txtQT_CD.Text = sQT;
        }


        private void btnAccept_Click(object sender, EventArgs e)
        {

            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void btnChonTatCa_Click(object sender, EventArgs e)
        {
            txtQT_Chon.Text += txtQT_CD.SelectedText + "\r\n";

        }



    }
}